package com.atguigu.reflect;

import java.lang.reflect.Constructor;

/**
 * Created by Smexy on 2024/4/1
 */
public class Demo16GetAnnotationAttrValue {

    public static void main(String[] args) throws NoSuchMethodException {

        Class<Demo14UseMyAnnotation> demo14UseMyAnnotationClass = Demo14UseMyAnnotation.class;

        Constructor<Demo14UseMyAnnotation> constructor = demo14UseMyAnnotationClass.getDeclaredConstructor();

        // 获取注解对象时指定注解类型
        Demo13MyAnnotation annotation = constructor.getAnnotation(Demo13MyAnnotation.class);

        // 调用注解声明属性时定义的抽象方法，即可获取到属性值
        String attrValue = annotation.helloAttr();

        System.out.println("attrValue = " + attrValue);
    }

}
